package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {
    /**
     * 通过购物车查看商品
     *
     * @return
     */
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    /**
     * 根据id查询一下购物车，看看是否有数据
     *
     * @param dishId
     * @return
     */
    @Select("select * from shopping_cart where dish_id=#{dishId}")
    ShoppingCart selectById(Long dishId);

    /**
     * 更新购物车
     *
     * @param build
     */
    @Update("update shopping_cart set number=#{number} where dish_id=#{dishId} or setmeal_id=#{setmealId}")
    void update(ShoppingCart build);

    /**
     * 插入一条数据
     *
     * @param shoppingCart
     */
    void insert(ShoppingCart shoppingCart);

    /**
     * 删除购物车
     *
     * @param
     */
    void delete(ShoppingCart shoppingCart);

    /**
     * 获得指定信息
     *
     * @param
     * @return
     */
    ShoppingCart getById(ShoppingCart shoppingCart);

    /**
     * 清空所欲的购物车
     */
    @Delete("delete from shopping_cart")
    void deleteAll();
}
